package com.fenxiangle.yueding.feature.focus.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

import com.fenxiangle.yueding.R;
import com.fenxiangle.yueding.entity.bo.AliPayBo;
import com.fenxiangle.yueding.entity.bo.ExtensionBo;
import com.fenxiangle.yueding.feature.extension.contract.ExtensionContract;
import com.fenxiangle.yueding.feature.extension.login.DaggerExtensionComponent;
import com.fenxiangle.yueding.feature.extension.login.ExtensionPresenterModule;
import com.suozhang.framework.framework.BaseActivity;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Home on 2018/9/1.
 */

public class ExtendCommissionActivity extends BaseActivity implements ExtensionContract.View, Toolbar.OnMenuItemClickListener {

    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.btn_commission)
    TextView btnCommission;
    @Inject
    ExtensionContract.Presenter presenter;
    @BindView(R.id.commission_moey)
    TextView commissionMoey;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_extendc_commission;
    }

    @Override
    protected void initInjector() {
        DaggerExtensionComponent.builder().extensionPresenterModule(new ExtensionPresenterModule(this)).build().inject(this);
    }

    @Override
    protected void initData() {
        toolbar.inflateMenu(R.menu.menu_next);
        toolbar.setOnMenuItemClickListener(this);
        initToolBar(toolbar, "推广佣金", true, true);
        presenter.user_Extension_Center();
    }



    @OnClick(R.id.btn_commission)
    public void onViewClicked(View view) {
        Intent intent = null;
        switch (view.getId()) {
            case R.id.btn_commission:
                if(extensionBo==null){
                    return;
                }
                intent = new Intent(this, WithdrawDepositActivity.class);
                intent.putExtra("extensionBo",extensionBo.getCommission());
                intent.putExtra("commissionType",1);
                startActivityForResult(intent,30000);
                break;
        }
    }
    ExtensionBo extensionBo=null;
    @Override
    public void ShowData(ExtensionBo s) {
        extensionBo=s;
        if (s != null) {
            commissionMoey.setText(s.getCommission()+"元");
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode==30000){
            if(data!=null && !TextUtils.isEmpty(data.getStringExtra("alibb"))){
                Intent intent=new Intent();
                intent.putExtra("alibb","111");
                setResult(30000,intent);
                finish();
            }
        }
    }

    @Override
    public void showLoginSuccess() {

    }

    @Override
    public void showAliPayBo(AliPayBo aliPayBo) {

    }

    @Override
    public void showWeiChatData(AliPayBo aliPayBo) {

    }

    @Override
    public void showError(String error) {

    }

    @Override
    public void showPwd(String pwd) {

    }

    @Override
    public void user_payment_set() {

    }

    @Override
    public boolean onMenuItemClick(MenuItem item) {
        int menuItemId = item.getItemId();
        if (menuItemId == R.id.action_wallet_detail) {
            Intent intent = new Intent(this, AccountDetailsActivity.class);
            startActivity(intent);
        }
        return false;
    }
}
